home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / C⁄C++ OS8 / AMReminder / DReminder.cp < prev    next >
Encoding:
Text File  |  1998-10-17  |  4.2 KB  |  259 lines  |  [TEXT/CWIE]

  1. // DReminder.cp -- data container class for AMReminder
  2.  
  3. #include "AMEngine.h"
  4. #include "PString.h"
  5. #include "DReminder.h"
  6.  
  7. #include <DateTimeUtils.h>
  8.  
  9. //----------
  10. DReminder::DReminder ()
  11. {
  12.     mDateTime.od.eraAlt = 0;
  13.     ::GetTime (&mDateTime.od.oldDate);
  14.     AssignPStr (mMessage, "\p");
  15.     mShowAlert = false;
  16.     mShowIcon = false;
  17.     mPlaySound = false;
  18.     mSoundIndex = 1;
  19. }
  20.  
  21. //----------
  22. DReminder::~DReminder ()
  23. {
  24. }
  25.  
  26. //----------
  27. void    DReminder::CopyFrom (
  28.     const DReminder&        inOther)
  29. {
  30.     mDateTime = inOther.mDateTime;
  31.     AssignPStr (mMessage, inOther.mMessage);
  32.     mShowAlert = inOther.mShowAlert;
  33.     mShowIcon = inOther.mShowIcon;
  34.     mPlaySound = inOther.mPlaySound;
  35.     mSoundIndex = inOther.mSoundIndex;
  36. }
  37.  
  38. //----------
  39. void    DReminder::ReadFromFile (
  40.     AMEngine*        engine)
  41. {
  42.     engine->ReadBytes (&mDateTime, sizeof (mDateTime));
  43.     engine->ReadPString (mMessage);
  44.     engine->ReadBytes (&mShowAlert, sizeof (mShowAlert));
  45.     engine->ReadBytes (&mShowIcon, sizeof (mShowIcon));
  46.     engine->ReadBytes (&mPlaySound, sizeof (mPlaySound));
  47.     engine->ReadBytes (&mSoundIndex, sizeof (mSoundIndex));
  48. }
  49.  
  50. //----------
  51. void    DReminder::WriteToFile (
  52.     AMEngine*        engine)
  53. {
  54.     engine->WriteBytes (&mDateTime, sizeof (mDateTime));
  55.     engine->WritePString (mMessage);
  56.     engine->WriteBytes (&mShowAlert, sizeof (mShowAlert));
  57.     engine->WriteBytes (&mShowIcon, sizeof (mShowIcon));
  58.     engine->WriteBytes (&mPlaySound, sizeof (mPlaySound));
  59.     engine->WriteBytes (&mSoundIndex, sizeof (mSoundIndex));
  60. }
  61.  
  62.  
  63. //----------
  64. LongDateRec        DReminder::GetDateTime () const
  65. {
  66.  
  67.     return mDateTime;
  68. }
  69.  
  70. //----------
  71. void    DReminder::SetDateTime (
  72.     LongDateRec        inValue)
  73. {
  74.     mDateTime = inValue;
  75.     
  76.     SignalDataChanged (idDateTime);
  77. }
  78.  
  79.  
  80. //----------
  81. StringPtr    DReminder::GetMessage (
  82.     Str255        outPtr) const
  83. {
  84.  
  85.     AssignPStr (outPtr, mMessage);
  86.     return (StringPtr)mMessage;
  87. }
  88.  
  89. //----------
  90. void    DReminder::SetMessage (
  91.     Str255        inValue)
  92. {
  93.     AssignPStr (mMessage, inValue);
  94.     
  95.     SignalDataChanged (idMessage);
  96. }
  97.  
  98. //----------
  99. void    DReminder::SetMessage (
  100.     CharsHandle        inValue)
  101. {
  102.     AssignPStr (mMessage, inValue);
  103.     
  104.     SignalDataChanged (idMessage);
  105. }
  106.  
  107.  
  108. //----------
  109. Boolean        DReminder::GetShowAlert () const
  110. {
  111.  
  112.     return mShowAlert;
  113. }
  114.  
  115. //----------
  116. void    DReminder::SetShowAlert (
  117.     Boolean        inValue)
  118. {
  119.     mShowAlert = inValue;
  120.     
  121.     SignalDataChanged (idShowAlert);
  122. }
  123.  
  124.  
  125. //----------
  126. Boolean        DReminder::GetShowIcon () const
  127. {
  128.  
  129.     return mShowIcon;
  130. }
  131.  
  132. //----------
  133. void    DReminder::SetShowIcon (
  134.     Boolean        inValue)
  135. {
  136.     mShowIcon = inValue;
  137.     
  138.     SignalDataChanged (idShowIcon);
  139. }
  140.  
  141.  
  142. //----------
  143. Boolean        DReminder::GetPlaySound () const
  144. {
  145.  
  146.     return mPlaySound;
  147. }
  148.  
  149. //----------
  150. void    DReminder::SetPlaySound (
  151.     Boolean        inValue)
  152. {
  153.     mPlaySound = inValue;
  154.     
  155.     SignalDataChanged (idPlaySound);
  156. }
  157.  
  158.  
  159. //----------
  160. SInt16        DReminder::GetSoundIndex () const
  161. {
  162.  
  163.     return mSoundIndex;
  164. }
  165.  
  166. //----------
  167. void    DReminder::SetSoundIndex (
  168.     SInt16        inValue)
  169. {
  170.     mSoundIndex = inValue;
  171.     
  172.     SignalDataChanged (idSoundIndex);
  173. }
  174.  
  175.  
  176. //----------
  177. StringPtr    DReminder::GetDateString (
  178.     Str255        outPtr) const
  179. {
  180.     LongDateTime        longSeconds;
  181.     static Str255        dateString;
  182.  
  183.     LongDateToSeconds (&mDateTime, &longSeconds);
  184.     LongDateString (&longSeconds, shortDate, dateString, nil);
  185.  
  186.     return dateString;
  187.  
  188. }
  189.  
  190. //----------
  191. void    DReminder::SetDateString (
  192.     Str255        inValue)
  193. {
  194.  
  195.     SignalDataChanged (idDateString);
  196. }
  197.  
  198.  
  199. //----------
  200. StringPtr    DReminder::GetTimeString (
  201.     Str255        outPtr) const
  202. {
  203.     LongDateTime        longSeconds;
  204.     static Str255        timeString;
  205.  
  206.     LongDateToSeconds (&mDateTime, &longSeconds);
  207.     LongTimeString (&longSeconds, false, timeString, nil);
  208.  
  209.     return timeString;
  210.  
  211. }
  212.  
  213. //----------
  214. void    DReminder::SetTimeString (
  215.     Str255        inValue)
  216. {
  217.  
  218.     SignalDataChanged (idTimeString);
  219. }
  220.  
  221.  
  222. //----------
  223. LongDateRec        DReminder::GetYearMonthDay () const
  224. {
  225.     return mDateTime;
  226.  
  227. }
  228.  
  229. //----------
  230. void    DReminder::SetYearMonthDay (
  231.     LongDateRec        inValue)
  232. {
  233.     mDateTime.ld.year = inValue.ld.year;
  234.     mDateTime.ld.month = inValue.ld.month;
  235.     mDateTime.ld.day = inValue.ld.day;
  236.     SignalDataChanged (idDateTime);
  237.  
  238.     SignalDataChanged (idYearMonthDay);
  239. }
  240.  
  241.  
  242. //----------
  243. LongDateRec        DReminder::GetHourMinute () const
  244. {
  245.     return mDateTime;
  246.  
  247. }
  248.  
  249. //----------
  250. void    DReminder::SetHourMinute (
  251.     LongDateRec        inValue)
  252. {
  253.     mDateTime.ld.hour = inValue.ld.hour;
  254.     mDateTime.ld.minute = inValue.ld.minute;
  255.     SignalDataChanged (idDateTime);
  256.  
  257.     SignalDataChanged (idHourMinute);
  258. }
  259.